#ifndef OBJECTBUCKET_H
#define OBJECTBUCKET_H

#include "actor.h"

/**
 * Pool of public IDs for MovingObjects on a map. By maintaining public ID
 * availability using bits, it can locate an available public ID fast while
 * using minimal memory access.
 */
struct ObjectBucket
{
    static int const int_bitsize = sizeof(unsigned) * 8;
    unsigned bitmap[256 / int_bitsize]; /**< Bitmap of free locations. */
    short free;                         /**< Number of empty places. */
    short next_object;                  /**< Next object to look at. */
    Actor *objects[256];

    ObjectBucket();
    int allocate();
    void deallocate(int);
};

#endif // OBJECTBUCKET_H
